Column

Scatterplot of tmin and tmax

Column

Box plot of snow depth from 2005 to 2012

Bar plot of average percipitation from 2005 to 2012

---
title: "Untitled"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(p8105.datasets)
library(plotly)
```

```{r}
data("ny_noaa")
ny_noaa <- ny_noaa %>%
  janitor::clean_names() %>%
  separate(date, into = c('year', 'month', 'day'), sep = "-") %>%
  mutate(
    tmax = as.numeric(tmax)/10,
    tmin = as.numeric(tmin)/10,
    prcp = prcp/10,
    year = as.numeric(year),
    month = as.numeric(month),
    day = as.numeric(day)
    ) %>% 
  filter(year %in% 2005:2010,
         month %in% c(12,1,2)) %>% 
  drop_na() %>% 
  sample_n(8000)
```

Column {data-width=650}
-----------------------------------------------------------------------

### Scatterplot of tmin and tmax

```{r}
ny_noaa %>% 
  plot_ly(x = ~tmin, y = ~tmax, type = "scatter", mode = "markers",
          alpha = .6, colors = "viridis", color = ~year) %>% 
  layout(xaxis = list(title = "Minimum temperature (degrees C)"), yaxis = list(title = "Maximum temperature (degrees C)"))
```

Column {data-width=350}
-----------------------------------------------------------------------

### Box plot of snow depth from 2005 to 2012

```{r}
ny_noaa %>%
  plot_ly(x = ~year, y = ~snwd, type = "box", colors = "viridis", fillcolor = ~year) %>%
  layout(xaxis = list(title = "Year"), yaxis = list(title = "Snow Depth"))
```

### Bar plot of average percipitation from 2005 to 2012

```{r}
ny_noaa %>% 
  group_by(year)%>%
  summarise(avg_prcp = mean(prcp)) %>%
  plot_ly(x = ~year, y = ~avg_prcp, type = "bar", mode = "markers",
          colors = "viridis", color = ~year) %>%
  layout(xaxis = list(title = "Year"), yaxis = list(title = "Average Percipitation"))
```